package uk.co.benbrown.jvis.model;

import java.util.ArrayList;
import java.util.List;

public class PhaseData {
    private String id;
    private List<Phase> phases;

    public List<Phase> getPhases() {
	return phases;
    }

    public void setPhases(List<Phase> phases) {
	this.phases = phases;
    }

    public void addPhase(Phase phase) {
	if (this.phases == null) {
	    this.phases = new ArrayList<Phase>();
	}
	this.phases.add(phase);
    }

    public void removePhase(Phase phase) {
	if (this.phases == null) {
	    this.phases = new ArrayList<Phase>();
	} else {
	    this.phases.remove(phase);
	}
    }

    public String getId() {
	return id;
    }

    public void setId(String id) {
	this.id = id;
    }

    public Phase findPhaseById(String id) {
	for (Phase phase : this.phases) {
	    if (id.equals(phase.getId())) {
		return phase;
	    }
	}
	return null;
    }

}
